/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package acciones;

import com.opensymphony.xwork2.ActionSupport;
import conexion.Conexion;
import modelo.Cliente;

/**
 *
 * @author Rodrigo
 */
public class GenerarCodigoCliente extends ActionSupport{
    private static final long serialVersionUID = 1L;
	private Cliente cliente = new Cliente();
        private Conexion conexion;

	public String execute() throws Exception {
                conexion = new Conexion();
                conexion.crearConexion();

                String consulta = " SELECT count(*) FROM dozen.cliente;";
		System.out.println(consulta);
                //conexion.ejecutarSQL(consulta);
                Object[][] obj =  conexion.ResultSetToArray(conexion.ejecutarSQLSelect(consulta));
                int codigo = Integer.parseInt( (String)obj[0][0] )+1;
                System.out.println("fsdfsdfsdfsdfds"+codigo);
                cliente.setClienteCod(""+codigo);
                return SUCCESS;
	}

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }




}
